package com.mofeng.myshop.domain.dto;

import com.baomidou.mybatisplus.annotation.TableField;
import com.mofeng.myshop.domain.dto.base.BaseDto;
import com.mofeng.myshop.domain.po.AddressMap;
import com.mofeng.myshop.until.MyUtil;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;

@Data
@AllArgsConstructor
@NoArgsConstructor
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
public class AddressMapDto extends BaseDto {

    @Schema(description = "项目ID")
    private String projectId;

    @Schema(description = "rcon端口")
    private Integer rconPort;

    @Schema(description = "服务器端口")
    private Integer serverPort;

    @Schema(description = "ip")
    private String ip;

    @Schema(description = "image")
    private String image;

    @Schema(description = "密码")
    private String password;

    @Schema(description = "地图类型")
    private Integer mapType;// 0 pve

    @Schema(description = "发货方式, 1 steamID  2 游戏ID")
    private String sendType;// 0 pve

    public AddressMap toAddressMap(){
        AddressMap addressMap = new AddressMap();
        toBaseEntity(addressMap);

        if (this.projectId != null) {
            addressMap.setProjectId(MyUtil.NumberUtil.asLong(this.projectId));
        }

        if (this.rconPort != null) {
            addressMap.setRconPort(this.rconPort);
        }
        if (this.serverPort != null) {
            addressMap.setServerPort(this.serverPort);
        }

        if (this.mapType != null) {
            addressMap.setMapType(this.mapType);
        }

        if (this.ip != null) {
            addressMap.setIp(this.ip);
        }

        if (this.password != null) {
            addressMap.setPassword(this.password);
        }

        if (this.sendType != null) {
            addressMap.setSendType(this.sendType);
        }

        if (this.image != null) {
            addressMap.setImage(this.image);
        }

        return addressMap;
    }
}
